#![deny(clippy::unwrap_used)]
#![allow(unused)]

use std::{env, fs, path};

use syn::File;
use tracing::debug;
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt as _;
use tracing_subscriber::util::SubscriberInitExt as _;
use tracing_subscriber::{EnvFilter, fmt};

#[tracing::instrument(skip_all)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args: Vec<String> = env::args().collect();
    (args.len() < 2).then(|| panic!("Usage: {} <filename>", args[0]));
    let filename = &args[1];
    let input = fs::read_to_string(filename)?;
    tracing_subscriber::registry()
        .with(fmt::layer())
        .with(EnvFilter::from_default_env())
        .init();

    Ok(())
}

#[allow(unused)]
pub fn write_to_file_for_log<T: std::fmt::Debug>(input: &T, file_name: &str) {
    use std::io::Write;
    let debug_str = format!("```rust\n{input:#?}\n```");
    #[allow(clippy::unwrap_used)]
    let mut file = std::fs::OpenOptions::new()
        .append(true)
        .create(true)
        .open(format!("{file_name}.md"))
        .unwrap();
    #[allow(clippy::unwrap_used)]
    writeln!(file, "{}", debug_str).unwrap();
}

#[cfg(test)]
mod test {
    mod test_;
}
